<?php include("config.php"); ?>

<html>
<head>
<title><?php echo($name); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>
<body>
<h1><?php echo($name); ?></h1>

<div style="background-color: blue; color: white;"><h3>Connexion</h3></div>

<?php
if((empty($_SESSION['login'])) AND (empty($_POST['login']))) {
?>
<form action="login.php" method="post">
<p>Nom d'utilisateur: <input type="text" name="login" /></p>
<p>Mot de passe: <input type="password" name="pass" /></p>
<p><input type="submit" value="Connexion" /></p>
</form>
<?php
}
elseif(!empty($_POST['login'])) {
$login = $_POST['login'];
$pass = md5($_POST['pass']);
dbconnect();
$req = mysql_query("SELECT * FROM ".$prefix."user WHERE `login` = '".$login."' LIMIT 1");
echo(mysql_error());
$data = mysql_fetch_assoc($req);

if($pass == $data['pass']) {
$_SESSION['login'] = $login;
$_SESSION['mail'] = $data['mail'];
header("Location: index.php");
}
else {
echo("<h3>Paire incorrecte</h3>");
}
}
?>
</form>
</body>
</html>
